<template>
	<view id="state_box">
		<view class="state_info">
			<view class="pdf_download">
				<my-icon name="pdf" size="48" @click="getOrderContract"></my-icon>
			</view>
			<view class="state_show">{{stateName}}</view>
		</view>
		<view class="step_box">
			<view class="separate_line"></view>
			<view class="step_icon">
				<OrderProgress :progress="orderStatus"></OrderProgress>
			</view>
		</view>
		<view class="showUlike">
		</view> 
	</view>
	</view>
</template>

<script>
	import OrderProgress from "./orderComponents/orderProgress.vue"
	import myIcon from "components/common/myIcon"
	import {getOrderInfoById,getOrderContractInfoById} from "apis/farmer/order"
	import {openPdf} from "utils/file"
	export default {
		data() {
			return {
				stateName: "下单成功",
				orderStatus: 1,
				orderId: null
			}
		},
		components:{OrderProgress,myIcon},
		methods: {
			async getOrderContract(){
				const {code,data} = await getOrderContractInfoById(this.orderId)
				if(code === 200 && data){
					openPdf(data)
				}else{
					this.$errorMsg("合同暂未生成")
				}
			}
		},
		async onLoad() {
			const {id,stateName} = this.$Route.query
			const {data,code,msg} = await getOrderInfoById(id)
			if (code !== 200) return this.$errorMsg(msg)
			this.orderStatus = data["orderStatus"]
			this.orderId = id
			this.stateName = stateName
		}
	}
</script>

<style>
	@import url("order_state.css");
</style>
